# CPBMI Python Homework 3-2
# Programmed by Seunghwan Kim

# 1)

fp = open("patient_weight_height.txt")
obesity_id = list()
for line in fp.readlines():
    data = line.split('\t')
    weight = float(data[1])
    height = float(data[2].strip())
    bmi = weight / (height / 100) ** 2
    if (bmi >= 40): obesity_id.append(data[0])
fp.close()

print "Obesity : ",
for oid in obesity_id:
    print oid,
print

# 2)

fp = open("patient_weight_height.txt")
fout = open("patient_bmi.txt", "w")

for line in fp.readlines():
    data = line.split('\t')
    patient_id = data[0]
    weight = float(data[1])
    height = float(data[2].strip())
    bmi = weight / (height / 100) ** 2
    fout.write("%s\t%2.2f\t%3.2f\t%2.2f\n" % (patient_id, weight, height, bmi))
fp.close()
fout.close()